﻿using System;
using System.Collections.Generic;
using Budgetsch.Web.EntityModel;
using Budgetsch.Web.Services;
using GalaSoft.MvvmLight;
using System.Collections.ObjectModel;

namespace Budgetsch.ViewModels.Costs
{
    public class AddCostVM : CostDetailVMBase
    {
        public event Action ItemAdded;
        public AddCostVM(BudgetschDomainContext context_)
            : base(context_)
        {
            Cost = new Cost() { StartDate = DateTime.Now.Date, EndDate = DateTime.Now.Date.AddYears(1)};
        }

        public override void Commit()
        {
            m_context.Costs.Add(Cost);
            m_context.SubmitChanges();
            ItemAdded();
        }
    }
}